﻿<UserControl x:Class="WiredTechSolutions.ShelvesetComparer.MainView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"
             Name="ShelvesetComparer"
             HorizontalAlignment="Stretch"
             xmlns:tfscontrols="clr-namespace:Microsoft.TeamFoundation.Controls.WPF;assembly=Microsoft.TeamFoundation.Controls"
             DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UserControl.Resources>
        <ResourceDictionary Source="/ShelvesetComparer;component/Resources/ResourceDictionary.xaml"/>
    </UserControl.Resources>

  <Grid Margin="6,6,6,6" >
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
    <Grid Width="Auto" HorizontalAlignment="Stretch" Grid.Row="0">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"></ColumnDefinition>
        <ColumnDefinition MinWidth="300"></ColumnDefinition>
      </Grid.ColumnDefinitions>

      <TextBlock Grid.Column="0" HorizontalAlignment="Stretch" Margin="0,0,200,0" Style="{StaticResource TextBlockStyle}">      
          <Run FontSize="18">Comparison Summary</Run> 
          <LineBreak/>
      </TextBlock>
      <tfscontrols:LabeledTextBox Grid.Column="1" AcceptsReturn="False" Name="SearchFilesTextBox" Width="Auto" HintText="Search files" KeyUp="SearchFilesTextBox_KeyUp" >
        <tfscontrols:LabeledTextBox.ToolTip>
          <TextBlock>
            Enter User account to list shelvesets
            <Image Source="/ShelvsetComparer;component/Resources/magnifier.png" />      
          </TextBlock>
        </tfscontrols:LabeledTextBox.ToolTip>
      </tfscontrols:LabeledTextBox>
    </Grid>
    <Grid Width="Auto" HorizontalAlignment="Stretch" Grid.Row="1">
      <Grid.ColumnDefinitions>
        <ColumnDefinition MinWidth="300"></ColumnDefinition>
        <ColumnDefinition Width="Auto"></ColumnDefinition>
      </Grid.ColumnDefinitions>

        <TextBlock Grid.Column="0" HorizontalAlignment="Stretch" Style="{StaticResource TextBlockStyle}">
          <Run FontSize="14">First Shelveset:</Run> <Run FontWeight="Bold" Text="{Binding ComparisonModel.FirstShelvesetName, ElementName=ShelvesetComparer}"/>
          <LineBreak/>
          <Run FontSize="14">Second Shelveset:</Run> <Run FontWeight="Bold" Text="{Binding ComparisonModel.SecondShelvesetName, ElementName=ShelvesetComparer}"/>
        </TextBlock>

      <TextBlock Grid.Column="1" Style="{StaticResource TextBlockStyle}">
          <Run FontSize="14">Number of common files:</Run> <Run FontWeight="Bold" Text="{Binding ComparisonModel.TotalNumberOfFiles, ElementName=ShelvesetComparer}"/>
          <LineBreak/>
          <Run FontSize="14">Matching files:</Run> <Run FontWeight="Bold" Text="{Binding ComparisonModel.NumberOfMatchingFiles, ElementName=ShelvesetComparer}"/>
          <LineBreak/>
          <Run FontSize="14">Different files:</Run> <Run FontWeight="Bold" Text="{Binding ComparisonModel.NumberOfDifferentFiles, ElementName=ShelvesetComparer}"/>
        </TextBlock>
    </Grid>
    
    <ListView Grid.Row="2" HorizontalAlignment="Stretch" Name="ComparisonFiles" ItemsSource="{Binding ComparisonModel.Files, ElementName=ShelvesetComparer}" MouseDoubleClick="ComparisonFiles_MouseDoubleClick" KeyUp="ComparisonFiles_KeyUp" SelectionMode="Single">
      <ListView.Resources>
        <Style x:Key="backgroundSelected" TargetType="{x:Type ListViewItem}">
          <Style.Triggers>
            <Trigger Property="IsSelected" Value="true">
              <Setter Property="Background" Value="LightYellow" />
            </Trigger>
            <Trigger Property="IsSelected" Value="false">
              <Setter Property="Background" Value="White" />
            </Trigger>            
          </Style.Triggers>
        </Style>
      </ListView.Resources>
      <ListView.View>
        <GridView>
          <GridViewColumn Header="First Shelveset" Width="300">
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <TextBlock x:Name="FirstFileNameTxt" Text="{Binding Path=FirstFileDisplayName}">
                  <TextBlock.Foreground>
                    <SolidColorBrush Color="{Binding Path=Color}" />
                  </TextBlock.Foreground>
                </TextBlock>
              </DataTemplate>
            </GridViewColumn.CellTemplate>
          </GridViewColumn>
          <GridViewColumn Header="Second Shelveset" Width="300">
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <TextBlock x:Name="SecondFileNameTxt" Text="{Binding Path=SecondFileDisplayName}">
                  <TextBlock.Foreground>
                    <SolidColorBrush Color="{Binding Path=Color}" />
                  </TextBlock.Foreground>
                </TextBlock>
              </DataTemplate>
            </GridViewColumn.CellTemplate>
          </GridViewColumn>
        </GridView>
      </ListView.View>
    </ListView>
  </Grid>
</UserControl>
